const http = {
    // 获取openid，sessionKey
    async getCode2Session(params, ctx) {
        try {
            const data = await ctx.curl('https://api.weixin.qq.com/sns/jscode2session', {
                method: "GET",
                data: {
                    appid: "wx692da63870d7aca9",
                    secret: "f2a50e79b75e3c7d482ebd4e6a416e6c",
                    js_code: params.code,
                    grant_type: "authorization_code"
                },
                dataType: "json"
            });
            if(data.res.status === 200) {
                return data.res.data;
            }
        } catch(e) {
            throw Error(e);
        }
    }
}
module.exports = http;